package cn.myjerry.io.charIO;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

/**
 * 纯文本的拷贝
 * @author Jerry
 *
 */
public class CopyFileDemo {
	public static void main(String[] args) {
		String srcPath = "/Users/zpon/Desktop/test.txt";
		String destPsth = "/Users/zpon/Desktop/test1.txt";
		try {
			copyFile(srcPath, destPsth);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public static void copyFile(String srcPath, String destPath) throws IOException {
		File src = new File(srcPath);
		File dest = new File(destPath);
		Reader reader = null;
		Writer writer = null;
		reader = new FileReader(src);
		writer = new FileWriter(dest, true);
		char[] car = new char[1024];
		int len = 0;
		while(-1 != (len = reader.read(car))) {
			writer.write(car, 0, len);
			writer.flush();
		}
		reader.close();
		writer.close();
	}
}
